#!/bin/sh

#### Script to enable IPv6 PDP context and set up IPv6 GPRS Interface ####
#                                                                        #
#    Original script by:                                                 #
#    Authors: Fuad Abinader (ext-fuad.junior@nokia.com)                  #
#             Vinicius Pinto (ext-vinicius.pinto@nokia.com)              #
#             Teemu Savolainen (teemu.savolainen@nokia.com)              #
#                                                                        #
##########################################################################

# Only enter the script if the opening connection type is GPRS
if [ $ICD_CONNECTION_TYPE ]; then
if [ $ICD_CONNECTION_TYPE == "DUMMY" ]; then

### IPv6 APN value ###
MY_IPv6_APN="ccinternet2.t-mobile.com"

### IPv6 APN username ###
MY_IPv6_USERNAME=""

### IPv6 APN password ###
MY_IPv6_PASSWORD=""

### Prioritary IPv6-specific DNS server ###
IPv6_DNS="2607:fb90:beef:a::1"

/usr/bin/dbus-send --system --print-reply --dest=com.nokia.csd.GPRS \
  /com/nokia/csd/gprs  com.nokia.csd.GPRS.Attach
/usr/bin/dbus-send --system --print-reply --dest=com.nokia.csd.GPRS \
  /com/nokia/csd/gprs  com.nokia.csd.GPRS.QuickConnect string:$MY_IPv6_APN\
  string:IPv6 string:$MY_IPv6_USERNAME string:$MY_IPv6_PASSWORD
ip6_string=$(dbus-send --system --print-reply --dest=com.nokia.csd.GPRS  /com/nokia/csd/gprs  com.nokia.csd.GPRS.GetStatus | grep string | cut -d '"' -f 2 | tail -1)
/sbin/ifconfig gprs0 $ip6_string up

if [ -f /var/run/resolv.conf ]; then
  /bin/mv /var/run/resolv.conf /var/run/resolv.conf.old
fi
echo "nameserver "$IPv6_DNS > /var/run/resolv.conf

fi
fi
